package com.abdulaziz.ms.ocv.gef.editor.command;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gef.commands.Command;

import com.abdulaziz.ms.OCV.OCVFactory;
import com.abdulaziz.ms.OCV.UMLClass;
import com.abdulaziz.ms.OCV.UMLClassDiagram;
import com.abdulaziz.ms.OCV.UMLOperation;
import com.abdulaziz.ms.OCV.UMLVariable;

public class OCVClassCreateCommand extends Command {
	private static final Dimension defaultDimension = new Dimension(150, 100);
	private static final String defaultName = "<new class>";

	private UMLClassDiagram parentUMClassDiagram;
	private UMLClass umlclass;
	private Rectangle classRectangle;

	@Override
	public void execute() {

		umlclass.setClassName(defaultName);

		if (classRectangle != null)
			umlclass.setConstraints(classRectangle);
		umlclass.setUmlDiagram(parentUMClassDiagram);
	}

	@Override
	public void undo() {
		umlclass.setUmlDiagram(null);
	}

	public void setUMLClass(UMLClass newUMLClass) {
		this.umlclass = newUMLClass;
	}

	public void setLocation(Point point) {
		classRectangle = new Rectangle();
		classRectangle.setLocation(point);
		classRectangle.setSize(defaultDimension);

	}

	public void setParent(UMLClassDiagram parentUMLClassDiagram) {
		this.parentUMClassDiagram = parentUMLClassDiagram;
	}

}
